﻿package mortal.game.view.guildNew.member
{
    import mortal.common.*;
    import mortal.game.cache.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.view.chat.chatPrivate.*;
    import mortal.game.view.guild.otherpanel.*;
    import mortal.game.view.guildNew.*;
    import mortal.game.view.guildNew.data.*;
    import mortal.mvc.interfaces.*;

    public class GuildNewMemProcessor extends Object
    {
        private var _view:IView;

        public function GuildNewMemProcessor()
        {
            this.initServer();
            return;
        }// end function

        public function initView(param1:IView) : void
        {
            this._view = param1;
            return;
        }// end function

        public function initServer() : void
        {
            EventUtil.addSelfEvent(EventName.Guild_memberList_get, this.getMemberListRequest, true);
            EventUtil.addSelfEvent(EventName.Guild_warnMemberList_get, this.getWarnMemberListRequest, true);
            EventUtil.addSelfEvent(EventName.GUILD_RECRUIT, this.guildRecruit, true);
            return;
        }// end function

        public function onViewShow() : void
        {
            this.addEvs(true);
            return;
        }// end function

        public function onViewHide() : void
        {
            this.addEvs(false);
            return;
        }// end function

        private function addEvs(param1:Boolean) : void
        {
            EventUtil.addSelfEvent(GuildNewLocalEvent.GuildNewMemberUpdate, this.updateMember, param1);
            EventUtil.addSelfEvent(GuildNewLocalEvent.GuildNewMemberSendMail, this.sendMail, param1);
            EventUtil.addSelfEvent(GuildNewLocalEvent.GuildNewMemberChat, this.sendChat, param1);
            return;
        }// end function

        private function updateMember(param1:Object) : void
        {
            if (this._view == null)
            {
                return;
            }
            if ((this._view as GuildNewModule).curPanel == null)
            {
                return;
            }
            var _loc_2:* = (this._view as GuildNewModule).curPanel as GuildNewMemberPanel;
            if (_loc_2)
            {
                _loc_2.update();
            }
            return;
        }// end function

        private function getMemberListRequest(event:DataEvent) : void
        {
            GameProxy.guild.getGuildMemberList(Cache.instance.guild.selfGuildInfo.guildID);
            return;
        }// end function

        private function getWarnMemberListRequest(event:DataEvent) : void
        {
            GameProxy.guild.getWarningMemberList();
            return;
        }// end function

        private function guildRecruit(event:DataEvent) : void
        {
            GameProxy.guild.recruit();
            return;
        }// end function

        private function sendMail(param1:Object) : void
        {
            if (GuildNewUtil.canSendGuildMail())
            {
                GuildMailPanel.instance.popUp();
            }
            return;
        }// end function

        private function sendChat(param1:Object) : void
        {
            ChatManager.addGuildWindow();
            ChatManager.guildWindow.show();
            return;
        }// end function

    }
}
